const Controller = require('egg').Controller;

class IfmtionController extends Controller {
	async getIfmtion() {
		const {
			ctx
		} = this
		const data = await ctx.service.ifmtion.getIfmtion()
		ctx.body = {
			code: 1,
			data
		}
	}
	async addIfmtion() {
		const {
			ctx
		} = this
		const data = await ctx.service.ifmtion.addIfmtion()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '添加成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '添加失败'
			}
		}
	}
	async editIfmtion() {
		const {
			ctx
		} = this
		const data = await ctx.service.ifmtion.editIfmtion()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '编辑成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '编辑失败'
			}
		}
	}
	async editType() {
		const {
			ctx
		} = this;
		const data = await ctx.service.ifmtion.editType()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '修改状态成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '修改状态失败'
			}
		}
	}
	async delIfmtion() {
		const {
			ctx
		} = this
		const data = await ctx.service.ifmtion.delIfmtion()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '删除成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '删除失败'
			}
		}
	}
}

module.exports = IfmtionController;